package com.hy.erp.inventory.service;

import java.util.List ;

import javax.ejb.Stateless ;

import org.jboss.seam.ScopeType ;
import org.jboss.seam.annotations.Name ;
import org.jboss.seam.annotations.Scope ;

import com.hy.enterprise.architecture.foundation.ArchitectureFoundationException;
import com.hy.enterprise.framework.service.business.AbstractBusinessService;
import com.hy.erp.inventory.dao.interfaces.IConversionStyleDao;
import com.hy.erp.inventory.pojo.ConversionStyle;
import com.hy.erp.inventory.pojo.interfaces.IConversionStyle;
import com.hy.erp.inventory.service.interfaces.IConversionStyleService;
/**
 * 
 * <ul>
 * <li>开发作者：李冰</li>
 * <li>设计日期：2010-10-13；时间：上午09:17:39</li>
 * <li>类型名称：ConversionStyleService</li>
 * <li>设计目的：</li>
 * </ul>
 * <ul>
 * <b>修订编号：</b>
 * <li>修订日期：</li>
 * <li>修订作者：</li>
 * <li>修订原因：</li>
 * <li>修订内容：</li>
 * </ul>
 */
@ Name ( "conversionStyleService" )
@ Scope ( ScopeType.STATELESS )
@ Stateless
public class ConversionStyleService extends AbstractBusinessService < IConversionStyle > implements IConversionStyleService{

	@Override
	public boolean addConversionStyle(IConversionStyle conversionStyle) {



		if ( null == conversionStyle)
		{
			return true ;
		}
		
		else
		{
			System.out
						.println ("ssssssssssssssssssssssffffffffffffffffhghhhhhhhhhhhhhhhhhhhhhh") ;


			IConversionStyleDao conversionStyleDao =
			                       ( IConversionStyleDao ) this
			                                          .getDao ( IConversionStyle.class ) ;
			
			return conversionStyleDao
			                .persist ( conversionStyle ) ;
		}
		
	
	
	
	}

	@Override
	public boolean modifyConversionStyle(IConversionStyle conversionStyle) {



		if ( ( null == conversionStyle )
			     || ( null == conversionStyle
			                                .getIdentifier ( ) )
			     || ( conversionStyle
			                        .getIdentifier ( )
			                        .trim ( )
			                        .length ( ) == 0 ) )
			{
				return true ;
			}
			else
			{

				IConversionStyleDao conversionStyleDao =
                    ( IConversionStyleDao ) this
                                       .getDao ( IConversionStyle.class ) ;

		
					
				if ( null == conversionStyle )
				{
					throw new ArchitectureFoundationException  (
					                                            "修改实体数据时发生错误，所需要修改的实体在数据库中并不存在" ) ;
				}
				
				
				return (conversionStyleDao
				                  .merge ( conversionStyle ) != null ) ;
			}
		
	
	
	
	}

	@Override
	public Integer removeConversionStyle(String[] conversionStyleIds) {



		if ( ( null == conversionStyleIds)
			     || ( conversionStyleIds.length == 0 ) )
			{
				return new Integer (
				                     0 ) ;
			}
			else
			{


				IConversionStyleDao conversionStyleDao =
                    ( IConversionStyleDao ) this
                                       .getDao ( IConversionStyle.class ) ;

		

				return conversionStyleDao
				                .remove ( conversionStyleIds ) ;
			}
	
	
	
	}

	@ Override
	public String [ ] addConversionStyle (
											Object [ ] conversionStyle )
	{




		if ( null == conversionStyle)
		{
			return null ;
		}
		
		else
		{
			

			IConversionStyleDao conversionStyleDao =
			                       ( IConversionStyleDao ) this
			                                          .getDao ( IConversionStyle.class ) ;

			ConversionStyle[] conversionStyles=new ConversionStyle[conversionStyle.length];
						for(int i=0;i<conversionStyle.length;i++)
						{
							ConversionStyle conversionStyle2=( ConversionStyle ) conversionStyle[i];
							conversionStyles[i]=conversionStyle2;
						}
						return conversionStyleDao
						                .persist ( conversionStyles ) ;
			
			
		}
		
	
	
	
	
	}

	@ Override
	public List < IConversionStyle > getAllConversionStyle ( )
	{
		IConversionStyleDao conversionStyleDao =
            ( IConversionStyleDao ) this
                               .getDao ( IConversionStyle.class ) ;



		return conversionStyleDao
		                .find ( ) ;
	}

	@ Override
	public String [ ] modifyConversionStyle (
												Object [ ] conversionStyle )
	{





		if ( null == conversionStyle)
		{
			return null ;
		}
		
		else
		{
			

			IConversionStyleDao conversionStyleDao =
			                       ( IConversionStyleDao ) this
			                                          .getDao ( IConversionStyle.class ) ;

			ConversionStyle[] conversionStyles=new ConversionStyle[conversionStyle.length];
						for(int i=0;i<conversionStyle.length;i++)
						{
							ConversionStyle conversionStyle2=( ConversionStyle ) conversionStyle[i];
							conversionStyles[i]=conversionStyle2;
						}
						return conversionStyleDao
						                .merge   ( conversionStyles ) ;
			
			
		}
		
	
	
	
	
	
	}

}
